package dome3;


import java.util.Comparator;
import java.util.PriorityQueue;

//无返回值无参数
@FunctionalInterface
interface NoParameterNoReturn {
    void test();
}
//无返回值一个参数
@FunctionalInterface
interface OneParameterNoReturn {
    void test(int a);
}
//无返回值多个参数
@FunctionalInterface
interface MoreParameterNoReturn {
    void test(int a,int b);
}




//有返回值无参数
@FunctionalInterface
interface NoParameterReturn {
    int test();
}
//有返回值一个参数
@FunctionalInterface
interface OneParameterReturn {
    int test(int a);
}
//有返回值多参数
@FunctionalInterface
interface MoreParameterReturn {
    int test(int a,int b);
}


public class Test {
    public static void main8(String[] args) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1.compareTo(o2);
            }
        });

        PriorityQueue<Integer> priorityQueue2 = new PriorityQueue<>((o1, o2) -> {return o1.compareTo(o2);});
//        PriorityQueue<Integer> priorityQueue2 = new PriorityQueue<>((o1, o2) -> o1.compareTo(o2));
    }
    public static void main7(String[] args) {
        MoreParameterReturn moreParameterReturn = (x,y) -> x+y;
        System.out.println(moreParameterReturn.test(10, 20));  // 30
    }
    public static void main6(String[] args) {
        OneParameterReturn oneParameterReturn = x -> x+10;
        System.out.println(oneParameterReturn.test(10)); //20
    }
    public static void main5(String[] args) {
        NoParameterReturn noParameterReturn = () -> {return 10;};
//        NoParameterReturn noParameterReturn = () -> 10;
        System.out.println(noParameterReturn.test()); //10
    }
    public static void main4(String[] args) {
        MoreParameterNoReturn moreParameterNoReturn = (int x,int y)->{System.out.println(x+y);};
//        MoreParameterNoReturn moreParameterNoReturn = (x,y) -> System.out.println(x+y);
        moreParameterNoReturn.test(1,2);
    }
    public static void main3(String[] args) {
        OneParameterNoReturn oneParameterNoReturn = (int x)->{System.out.println(x);};
//        OneParameterNoReturn oneParameterNoReturn = x -> System.out.println(x);
        oneParameterNoReturn.test(10);
    }
    public static void main2(String[] args) {
        NoParameterNoReturn noParameterNoReturn = ()->{System.out.println("test()...");};
//        NoParameterNoReturn noParameterNoReturn = ()->System.out.println("test()...");
        noParameterNoReturn.test();;
    }
    public static void main1(String[] args) {
        //相当于一个匿名内部类  实现了接口并且实现了接口的方法
        NoParameterNoReturn noParameterNoReturn = new NoParameterNoReturn() {
            @Override
            public void test() {
                System.out.println("test()...");
            }
        };
        noParameterNoReturn.test();
    }
}
